const DB = require('@config/db')
const mongoose = require('mongoose')
// const ObjectId = mongoose.Types.ObjectId
mongoose.Promise = global.Promise  // 防止Mongoose: mpromise 错误

const userSchema = DB.base.Schema({
  // _id: { type: ObjectId },
  username: {
    type: String,
    required: true
  },
  password: {
    type: String,
    require: true
  },
  age: {
    type: Number,
    require: true,
    default: null
  },
  avatar: {
    type: String,
    require: true,
    default: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png'
  },
  create_time: {
    type: Number,
    require: true,
    default: null
  },
  update_time: {
    type: Number,
    require: true,
    default: null
  }
})

const User = DB.base.model('User', userSchema)

module.exports = User